package dao

import "main/global"

func GetOneByFields[T any](where *T, data *T) {
	global.DB.Where(where).Limit(1).Find(&data)
}

func GetAllByFields[T any](data *[]T) {
	global.DB.Find(&data)
}

func GetListByFields[T any](where *T, data *[]T) {
	global.DB.Where(where).Find(&data)
}

func AddFields[T any](data *T) {
	global.DB.Create(&data)
}

func UpdateFields[T any](data *T) {
	global.DB.Updates(&data)
}

func DeleteFields[T any](data *T) {
	global.DB.Delete(&data)
}
